package com.doge.walknovel.business.home.profile.topup

import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.doge.walknovel.api.model.RechargeProductInfo
import com.doge.walknovel.core.base.LoadStatus

class TopUpViewModel constructor(private val repository: TopUpRepository) : ViewModel() {
    val loading: LiveData<LoadStatus> = repository.loading
    val dataList: LiveData<List<RechargeProductInfo>> = repository.dataList
    val tips: LiveData<String?> = repository.tips

    fun initialize() {
        repository.request()
    }
}


class TopUpViewModelFactory : ViewModelProvider.Factory {
    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
        val repository = TopUpRepository()
        if (modelClass.isAssignableFrom(TopUpViewModel::class.java)) {
            return TopUpViewModel(repository) as T
        }
        //noinspection unchecked
        throw IllegalArgumentException("Unknown ViewModel class")
    }
}

